<?php

class Application_Model_DbTable_Users extends Zend_Db_Table_Abstract {

    protected $_name = 'users';
	
	public function getUser($id){
		$row = $this->fetchRow("id=".$id);
        return $row;
	}

	public function checkUser($name,$password){
		$row = $this->fetchRow("(name='".$name."' AND "."password='".$password."') OR (email='".$name."' AND "."password='".$password."')");
		return $row;
	}
		
	public function createUser($name,$password,$email,$location,$address){
		$row = $this->createRow();
		$row->name = $name;
		$row->password = $password;
		$row->email = $email;
		$row->location = $location;
		$row->address = $address;
		$row->save();
		return $row;
	}
	
	public function checkUserName($name){
		$rows = $this->fetchRow("name='".$name."'");
		return $rows;
	}
	
	public function updateUser($id,$name,$password,$email,$location,$address){
		$row = $this->getUser($id);
		$row->name = $name;
		$row->password = $password;
		$row->email = $email;
		$row->location = $location;
		$row->address = $address;
		$row->save();
		return $row;
	}
}
